package com.example.demo.listener;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * Created by Administrator on 2018\11\13 0013.
 */
@SpringBootApplication
public class ApplicationDemo {
    public static void main(String[] args) {
        //创建一个可执行的spring应用程序
        SpringApplication application = new SpringApplication(ApplicationDemo.class);
        //配置事件监听器
//        application.addListeners(new MyApplicationListener());
        //配置应用程序上下文
        ConfigurableApplicationContext context =application.run(args);
        //发布事件
        context.publishEvent(new MyApplicationEvent(new Object()));
        //关闭监视器
        context.close();
    }

}
